import { trans } from '@utils/common'
import { post, get, postL, getL } from '@utils/http'
import { SERVE_URL } from '@utils/config'

export default {
    apis: {
        UPLOAD: SERVE_URL + '/oss/uploadFile',

        //================参数===========
        ARGUMENT_LIST: SERVE_URL + 'apiExp/manager/sysConfig/pageQuery',
        ARGUMENT_SAVE: SERVE_URL + 'apiExp/manager/sysConfig/save',
        ARGUMENT_DELETE: SERVE_URL + 'apiExp/manager/sysConfig/del',
        ARGUMENT_EDIT: SERVE_URL + 'apiExp/manager/sysConfig/update',

        //================操作日志===========
        OPERATELOG_LIST: SERVE_URL + 'apiExp/manager/operateLog/pageQuery',
        OPERATELOG_LIST_DELETE: SERVE_URL + 'apiExp/manager/operateLog/detail',
        LOGINLOG_LIST: SERVE_URL + 'apiExp/manager/loginLog/pageQuery',

        //================字典============
        DICTIONARY_ALL: SERVE_URL + 'apiExp/manager/sysDict/pageQuery', // 字典 传参查值
        DICTIONARY_LIST: SERVE_URL + 'apiExp/manager/sysDictType/pageQuery', // 字典列表
        DICTIONARY_SAVE: SERVE_URL + 'apiExp/manager/sysDictType/save', // 字典 新增
        DICTIONARY_EDIT: SERVE_URL + 'apiExp/manager/sysDictType/update', // 字典 修改
        DICTIONARY_DELETE: SERVE_URL + 'apiExp/manager/sysDictType/del', // 字典 删除

        DICTIONARY_VALUE_LIST: SERVE_URL + 'apiExp/manager/sysDict/pageQuery', // 字典 子值查询
        DICTIONARY_VALUE_SAVE: SERVE_URL + 'apiExp/manager/sysDict/save', // 字典 子值新增
        DICTIONARY_VALUE_EDIT: SERVE_URL + 'apiExp/manager/sysDict/update', // 字典 子值修改
        DICTIONARY_VALUE_DELETE: SERVE_URL + 'apiExp/manager/sysDict/del', // 字典 子值删除

        //============第三方参数配置
        SYS_FINDANTCHAIN: SERVE_URL + 'apiExp/system/systemConfiguration/findAntChain',
        SYS_FINDOSS: SERVE_URL + 'apiExp/system/systemConfiguration/findOss',
        SYS_FINDSESAMECHARGE: SERVE_URL + 'apiExp/system/systemConfiguration/findSeSameCharge',
        SYS_FINDSHUNFEN: SERVE_URL + 'apiExp/system/systemConfiguration/findShunFeng',
        SYS_FINDAZFB: SERVE_URL + 'apiExp/system/systemConfiguration/findZhiFuBao',
        SYS_FINDANTCHAIN_UPDATE: SERVE_URL + 'apiExp/system/systemConfiguration/antChainUpdate',
        SYS_FINDOSS_UPDATE: SERVE_URL + 'apiExp/system/systemConfiguration/ossUpdate',
        SYS_FINDSESAMECHARGE_UPDATE: SERVE_URL + 'apiExp/system/systemConfiguration/seSameChargeUpdate',
        SYS_FINDSHUNFEN_UPDATE: SERVE_URL + 'apiExp/system/systemConfiguration/shunFengUpdate',
        SYS_FINDAZFB_UPDATE: SERVE_URL + 'apiExp/system/systemConfiguration/zhiFuBaoUpdate',
        // ============第三方配置  物流
        LOGISTICS_LIST: SERVE_URL + 'apiExp/logistics/config/list',
        LOGISTICS_ADD: SERVE_URL + 'apiExp/logistics/config/add',
        LOGISTICS_EDIT: SERVE_URL + 'apiExp/logistics/config/edit',
        LOGISTICS_DELETE: SERVE_URL + 'apiExp/logistics/config/delete',
        LOGISTICS_DEFAULT: SERVE_URL + 'apiExp/logistics/config/setDefaultConfig',

        //第三方配置  oss ==========
        OSS_CONFIG_LIST: SERVE_URL + 'apiExp/oss/config/list',
        OSS_CONFIG_EDIT: SERVE_URL + 'apiExp/oss/config/edit',
        OSS_CONFIG_DELETE: SERVE_URL + 'apiExp/oss/config/delete',
        OSS_CONFIG_ADD: SERVE_URL + 'apiExp/oss/config/add',
        OSS_CONFIG_DEFAULT: SERVE_URL + 'apiExp/oss/config/setDefaultConfig',

        // 第三方配置  短信==============
        SMS_CONFIG_LIST: SERVE_URL + 'apiExp/sms/config/list',
        SMS_CONFIG_EDIT: SERVE_URL + 'apiExp/sms/config/edit',
        SMS_CONFIG_DELETE: SERVE_URL + 'apiExp/sms/config/delete',
        SMS_CONFIG_ADD: SERVE_URL + 'apiExp/sms/config/add',
        SMS_CONFIG_DEFAULT: SERVE_URL + 'apiExp/sms/config/setDefaultConfig',

        //第三方配置 合同 =================
        CONTRACT_CONFIG_LIST: SERVE_URL + 'apiExp/contract/config/list',
        CONTRACT_CONFIG_ADD: SERVE_URL + 'apiExp/contract/config/add',
        CONTRACT_CONFIG_EDIT: SERVE_URL + 'apiExp/contract/config/edit',
        CONTRACT_CONFIG_DELETE: SERVE_URL + 'apiExp/contract/config/delete',
        CONTRACT_CONFIG_DEFAULT: SERVE_URL + 'apiExp/contract/config/setDefaultConfig',

        //第三方配置 合同 =================
        PAY_CONFIG_LIST: SERVE_URL + 'apiExp/pay/config/list',
        PAY_CONFIG_ADD: SERVE_URL + 'apiExp/pay/config/add',
        PAY_CONFIG_EDIT: SERVE_URL + 'apiExp/pay/config/edit',
        PAY_CONFIG_DELETE: SERVE_URL + 'apiExp/pay/config/delete',
        PAY_CONFIG_DEFAULt: SERVE_URL + 'apiExp/pay/config/setDefaultConfig',
    },

    // 参数 列表
    async arguments(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.ARGUMENT_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    // 参数 新增
    async argumentSave(param) {
        const res = await trans(postL(this.apis.ARGUMENT_SAVE, param));
        return res.success;
    },

    // 参数 修改
    async argumentEdit(param) {
        const res = await trans(postL(this.apis.ARGUMENT_EDIT, param));
        return res.success;
    },

    // 参数 删除
    async argumentDelete(ids) {
        const res = await trans(getL(this.apis.ARGUMENT_DELETE, { ids }));
        return res.success;
    },

    // 日志 列表
    async operateLog(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.OPERATELOG_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },

    // 日志 详情
    async operateLogDet(id) {
        const res = await trans(getL(this.apis.OPERATELOG_LIST_DELETE, { id }));
        return res.data;
    },

    // 登陆日志 列表
    async loginLog(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.LOGINLOG_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize, orderByColumn: 'createTime', orderDirection: 'desc' },
            })
        );
        return res;
    },

    // 字典 查子值
    async dictionaryAll(key) {
        const res = await trans(
            post(this.apis.DICTIONARY_ALL, {
                bo: { typeCode: key },
                page: { currentPage: 1, pageSize: 9999 },
            })
        );
        if (!res.success) return false;
        if (!key) return res.list;
        // let data = null
        // if (res.list) {
        //     for (let i = 0; i < res.list.length; i++) {
        //         if (res.list[i].typeCode === key) {
        //             return res.list[i].list
        //         }
        //     }
        // }
        return res.list;
    },

    // 字典 查询
    async dictionarys(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.DICTIONARY_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },

    // 字典 新增
    async dictionarySave(param) {
        const res = await trans(postL(this.apis.DICTIONARY_SAVE, param));
        return res.success;
    },

    // 字典 修改
    async dictionaryEdit(param) {
        const res = await trans(postL(this.apis.DICTIONARY_EDIT, param));
        return res.success;
    },

    // 字典 删除
    async dictionaryDelete(id) {
        const res = await trans(getL(this.apis.DICTIONARY_DELETE, { id }));
        return res.success;
    },

    // 字典 子值查询
    async dictionarySelect(pageNo, pageSize = 20, param) {
        const res = await trans(
            postL(this.apis.DICTIONARY_VALUE_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },

    // 字典 子值新增
    async dictionaryValueSave(param) {
        const res = await trans(postL(this.apis.DICTIONARY_VALUE_SAVE, param));
        return res.success;
    },

    // 字典 子值修改
    async dictionaryValueEdit(param) {
        const res = await trans(postL(this.apis.DICTIONARY_VALUE_EDIT, param));
        return res.success;
    },

    // 字典 子值删除
    async dictionaryValueDelete(id) {
        const res = await trans(getL(this.apis.DICTIONARY_VALUE_DELETE, { id }));
        return res.success;
    },

    // 第三方配置获取 start
    async sysFindAntChain(param) {
        const res = await trans(postL(this.apis.SYS_FINDANTCHAIN, param));
        return res;
    },
    async sysFindOss(param) {
        const res = await trans(postL(this.apis.SYS_FINDOSS, param));
        return res;
    },
    async sysFindSeSameCharge(param) {
        const res = await trans(postL(this.apis.SYS_FINDSESAMECHARGE, param));
        return res;
    },
    async sysFindShunFen(param) {
        const res = await trans(postL(this.apis.SYS_FINDSHUNFEN, param));
        return res;
    },
    async sysFindZFB(param) {
        const res = await trans(postL(this.apis.SYS_FINDAZFB, param));
        return res;
    },
    // end
    // 第三方配置修改 start
    async sysFindAntChainUpdate(param) {
        const res = await trans(postL(this.apis.SYS_FINDANTCHAIN_UPDATE, param));
        return res;
    },
    async sysFindOssUpdate(param) {
        const res = await trans(postL(this.apis.SYS_FINDOSS_UPDATE, param));
        return res;
    },
    async sysFindSeSameChargeUpdate(param) {
        const res = await trans(postL(this.apis.SYS_FINDSESAMECHARGE_UPDATE, param));
        return res;
    },
    async sysFindShunFenUpdate(param) {
        const res = await trans(postL(this.apis.SYS_FINDSHUNFEN_UPDATE, param));
        return res;
    },
    async sysFindZFBUpdate(param) {
        const res = await trans(postL(this.apis.SYS_FINDAZFB_UPDATE, param));
        return res;
    },
    //物流第三方
    async logisticsList(param) {
        const res = await trans(post(this.apis.LOGISTICS_LIST, param));
        return res.data;
    },
    async logisticsAdd(param) {
        const res = await trans(post(this.apis.LOGISTICS_ADD, param));
        return res.data;
    },
    async logisticsEdit(param) {
        const res = await trans(post(this.apis.LOGISTICS_EDIT, param));
        return res.data;
    },
    async logisticsDelete(configId) {
        const res = await trans(getL(this.apis.LOGISTICS_DELETE, { configId }));
        return res.data;
    },
    async logisticsDefault(configId) {
        const res = await trans(getL(this.apis.LOGISTICS_DEFAULt, { configId }));
        return res.data;
    },
    //oss第三方
    async ossConfigList(param) {
        const res = await trans(post(this.apis.OSS_CONFIG_LIST, param));
        return res.data;
    },
    async ossConfigAdd(param) {
        const res = await trans(post(this.apis.OSS_CONFIG_ADD, param));
        return res.data;
    },
    async ossConfigEdit(param) {
        const res = await trans(post(this.apis.OSS_CONFIG_EDIT, param));
        return res.data;
    },
    async ossConfigDelete(configId) {
        const res = await trans(getL(this.apis.OSS_CONFIG_DELETE, { configId }));
        return res.data;
    },
    async ossConfigDefault(configId) {
        const res = await trans(getL(this.apis.OSS_CONFIG_DEFAULt, { configId }));
        return res.data;
    },
    //短信第三方
    async smsConfigList(param) {
        const res = await trans(post(this.apis.SMS_CONFIG_LIST, param));
        return res.data;
    },
    async smsConfigAdd(param) {
        const res = await trans(post(this.apis.SMS_CONFIG_ADD, param));
        return res.data;
    },
    async smsConfigEdit(param) {
        const res = await trans(post(this.apis.SMS_CONFIG_EDIT, param));
        return res.data;
    },
    async smsConfigDelete(configId) {
        const res = await trans(getL(this.apis.SMS_CONFIG_DELETE, { configId }));
        return res.data;
    },
    async smsConfigDefault(configId) {
        const res = await trans(getL(this.apis.SMS_CONFIG_DEFAULt, { configId }));
        return res.data;
    },
    //合同第三方
    async contractConfigList(param) {
        const res = await trans(post(this.apis.CONTRACT_CONFIG_LIST, param));
        return res.data;
    },
    async contractConfigAdd(param) {
        const res = await trans(post(this.apis.CONTRACT_CONFIG_ADD, param));
        return res.data;
    },
    async contractConfigEdit(param) {
        const res = await trans(post(this.apis.CONTRACT_CONFIG_EDIT, param));
        return res.data;
    },
    async contractConfigDelete(configId) {
        const res = await trans(getL(this.apis.CONTRACT_CONFIG_DELETE, { configId }));
        return res.data;
    },
    async contractConfigDefault(configId) {
        const res = await trans(getL(this.apis.CONTRACT_CONFIG_DEFAULT, { configId }));
        return res.data;
    },
    //第三方 支付配置
    async payConfigList(param) {
        const res = await trans(post(this.apis.PAY_CONFIG_LIST, param));
        return res.data;
    },
    async payConfigAdd(param) {
        const res = await trans(post(this.apis.PAY_CONFIG_ADD, param));
        return res.data;
    },
    async payConfigEdit(param) {
        const res = await trans(post(this.apis.PAY_CONFIG_EDIT, param));
        return res.data;
    },
    async payConfigDelete(configId) {
        const res = await trans(getL(this.apis.PAY_CONFIG_DELETE, { configId }));
        return res.data;
    },
    async payConfigDefault(configId) {
        const res = await trans(getL(this.apis.PAY_CONFIG_DEFAULt, { configId }));
        return res.data;
    },
    // end
};
